*Graph Settings
grstyle clear
set scheme s2color
grstyle init
grstyle set plain, box
grstyle color background white
grstyle set color Set1
grstyle yesno draw_major_hgrid yes
grstyle yesno draw_major_ygrid yes
grstyle color major_grid gs8
grstyle linepattern major_grid dot
grstyle set legend 4, box inside
grstyle color ci_area gs12%50


xtset ccode year

xtreg absrpe new1 h_polcon3 rpe_gdp i.year, fe
outreg2 using leaders1, word append dec(3)
xtreg absrpe new1 h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year, fe
outreg2 using leaders1, word append dec(3)
xtreg absrpe c.new1##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year, fe
outreg2 using leaders1, word append dec(3)


xtreg absrpe solschdum h_polcon3 rpe_gdp i.year, fe
outreg2 using leaders1, word append dec(3)
xtreg absrpe solschdum h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year, fe
outreg2 using leaders1, word append dec(3)
xtreg absrpe c.solschdum##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year, fe
outreg2 using leaders1, word append dec(3)


xtreg absrpe c.new1##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year, fe
margins, at( h_polcon3=(0 (0.062) .7255996) new1=(0 1))
marginsplot
xtreg absrpe c.solschdum##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year, fe
margins, at( h_polcon3=(0 (0.062) .7255996) solschdum=(0 1))
marginsplot




diff absrpe, t(new2) p(leaderdeath) cov(h_polcon3 csh_g entrytype age gender life_exp logpop loggdppc war rpe_gdp) kernel id(ccode) bs reps(500)
outreg2 using did1, word append

diff absrpe, t(new3) p(leaderdeath) cov(h_polcon3 csh_g entrytype age gender life_exp logpop loggdppc war rpe_gdp) kernel id(ccode) bs reps(500)
outreg2 using did1, word append

diff absrpe, t(new5) p(leaderdeath) cov(h_polcon3 csh_g entrytype age gender life_exp logpop loggdppc war rpe_gdp) kernel id(ccode) bs reps(500)
outreg2 using did1, word append




diff absrpe, t(postsols2) p(leaderdeath) cov(h_polcon3 csh_g entrytype age gender life_exp logpop loggdppc war rpe_gdp) kernel id(ccode) bs reps(500)
outreg2 using did1, word append

diff absrpe, t(postsols3) p(leaderdeath) cov(h_polcon3 csh_g entrytype age gender life_exp logpop loggdppc war rpe_gdp) kernel id(ccode) bs reps(500)
outreg2 using did1, word append

diff absrpe, t(postsols5) p(leaderdeath) cov(h_polcon3 csh_g entrytype age gender life_exp logpop loggdppc war rpe_gdp) kernel id(ccode) bs reps(500)
outreg2 using did1, word append


*** ROBUSTNESS
*** Hanson's State Capacity Measure
gen abshanson = (( lld_capacity - L.lld_capacity ) / lld_capacity )

xtreg abshanson new1 h_polcon3 lld_capacity i.year, fe
outreg2 using leaders2, word append dec(3)

xtreg abshanson new1 h_polcon3 csh_g entrytype age gender logpop loggdppc war lld_capacity i.year, fe
outreg2 using leaders2, word append dec(3)

xtreg abshanson c.new1##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war lld_capacity i.year, fe
outreg2 using leaders2, word append dec(3)


xtreg abshanson solschdum h_polcon3 lld_capacity i.year, fe
outreg2 using leaders2, word append dec(3)

xtreg abshanson solschdum h_polcon3 csh_g entrytype age gender logpop loggdppc war lld_capacity i.year, fe
outreg2 using leaders2, word append dec(3)

xtreg abshanson c.solschdum##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war lld_capacity i.year, fe
outreg2 using leaders2, word append dec(3)


*** FOR THE RESPONSE LETTER

***Coalition Govt
gen coalition = 0 if cpds_tg != .
replace coalition = 1 if cpds_tg == 4

xtreg absrpe new1 coalition rpe_gdp i.year, fe
outreg2 using coalition, word append dec(3)
xtreg absrpe new1 coalition age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using coalition, word append dec(3)
xtreg absrpe c.new1##c.coalition age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using coalition, word append dec(3)
xtreg absrpe solschdum coalition rpe_gdp i.year, fe
outreg2 using coalition, word append dec(3)
xtreg absrpe solschdum coalition age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using coalition, word append dec(3)
xtreg absrpe c.solschdum##c.coalition age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using coalition, word append dec(3)

***Democracy
***Cheibub, Gandhi, and Vreeland
xtreg absrpe new1 br_dem rpe_gdp i.year, fe
outreg2 using br_dem, word append dec(3)
xtreg absrpe new1 br_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using br_dem, word append dec(3)
xtreg absrpe c.new1##c.br_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using br_dem, word append dec(3)
xtreg absrpe solschdum br_dem rpe_gdp i.year, fe
outreg2 using br_dem, word append dec(3)
xtreg absrpe solschdum br_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using br_dem, word append dec(3)
xtreg absrpe c.solschdum##c.br_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using br_dem, word append dec(3)

*** Cheibub, Gandhi, and Vreeland - Stratified

xtreg absrpe new1 h_polcon3 age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year if bmr_dem==0, fe
outreg2 using br_dem_strat, word append dec(3)
xtreg absrpe solschdum h_polcon3 age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year if bmr_dem==0, fe
outreg2 using br_dem_strat, word append dec(3)
xtreg absrpe new1 h_polcon3 age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year if bmr_dem==1, fe
outreg2 using br_dem_strat, word append dec(3)
xtreg absrpe solschdum h_polcon3 age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year if bmr_dem==1, fe
outreg2 using br_dem_strat, word append dec(3)



***Boix-Miller-Rosato
xtreg absrpe new1 bmr_dem rpe_gdp i.year, fe
outreg2 using bmr_dem, word append dec(3)
xtreg absrpe new1 bmr_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using bmr_dem, word append dec(3)
xtreg absrpe c.new1##c.bmr_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using bmr_dem, word append dec(3)
xtreg absrpe solschdum bmr_dem rpe_gdp i.year, fe
outreg2 using bmr_dem, word append dec(3)
xtreg absrpe solschdum bmr_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using bmr_dem, word append dec(3)
xtreg absrpe c.solschdum##c.bmr_dem age gender entrytype logpop loggdppc csh_g war rpe_gdp i.year, fe
outreg2 using bmr_dem, word append dec(3)


****DFBeta Analysis

reg absrpe c.new1##c.h_polcon3 csh_g entrytype age gender logpop loggdppc war rpe_gdp i.year i.ccode
dfbeta new1
dfbeta h_polcon3
dfbeta c.new1#c.h_polcon3
rename _dfbeta_1 dfbeta_new1
rename _dfbeta_2 dfbeta_polcon
rename _dfbeta_3 dfbeta_interaction

gen obs_id = _n

local threshold = 2/sqrt(_N)
display "Influence Threshold: " `threshold'

twoway (scatter dfbeta_new1 obs_id, mcolor(blue) msymbol(O) msize(vsmall)) (scatter dfbeta_polcon obs_id, mcolor(red) msymbol(T) msize(vsmall)) /// Smaller triangles for polcon
    (scatter dfbeta_interaction obs_id, mcolor(green) msymbol(D) msize(vsmall)) /// Smaller diamonds for interaction
    (function y=`threshold', range(obs_id) lpattern(dash) lcolor(black)) /// Upper Threshold Line
    (function y=-`threshold', range(obs_id) lpattern(dash) lcolor(black)), /// Lower Threshold Line
    title("DFBeta Values with Influence Thresholds") ///
    xlabel(, angle(45)) ///
    ytitle("DFBeta Influence Values")    xtitle("Observation Index")     legend(order(1 "Leader Change (new1) - Circle" ///
                 2 "Political Constraints (h_polcon3) - Triangle" ///
                 3 "Interaction (new1 × h_polcon3) - Diamond" ///
                 4 "Influence Threshold (+2/√N, -2/√N) - Dashed Line") ///
           region(lcolor(black)) size(small) position(6)) /// 
    yline(`threshold' -`threshold', lcolor(black) lpattern(dash)) 

